﻿#ifndef RTSPCODECWIDGET_H
#define RTSPCODECWIDGET_H

#include <QtGui>
#include <QtNetwork>
#include <QThread>
#include <QtWidgets>
#include <QQuickImageProvider>
#include "rtspcodecthread.h"

class QImageProvider : public QQuickImageProvider
{
public:
    explicit QImageProvider();
public:
    QImage voideImg;
public:
    QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize) override;
};

class RtspCodecWidget : public QWidget
{
    Q_OBJECT
public:
    explicit RtspCodecWidget(QWidget *parent = 0);
    ~RtspCodecWidget();
private:
    RtspCodecThread     *m_rtspCodec;
    QImageProvider      *m_imageProvider;
public:
    QImageProvider      *imageProvider() const;
private slots:
    void restart();
    void close();
    void checkVideo();
public slots:
    void open(const QString &url);
    void updateImage(const QImage &image);
signals:
    void updateVideo();
};

#endif // RTSPCODECWIDGET_H
